package net.yegong.util;

/**
 * 
 * The Tuple which can contains five different elements.
 * @author cooper
 * 
 */
public final class Tuple5<U, V, W, X, Y> {

	public Tuple5(U u, V v, W w, X x, Y y) {
		this.u = u;
		this.v = v;
		this.w = w;
		this.x = x;
		this.y = y;
	}

	public U get1() {
		return u;
	}

	public V get2() {
		return v;
	}

	public W get3() {
		return w;
	}

	public X get4() {
		return x;
	}

	public Y get5() {
		return y;
	}

	@Override
	public String toString() {
		return "[" + u + ", " + v + ", " + w + ", " + x + ", " + y + "]";
	}

	@Override
	public int hashCode() {
		int hash1 = 0;
		int hash2 = 0;
		int hash3 = 0;
		int hash4 = 0;
		int hash5 = 0;
		if (u != null) {
			hash1 = u.hashCode();
		}
		if (v != null) {
			hash2 = v.hashCode();
		}
		if (w != null) {
			hash3 = w.hashCode();
		}
		if (x != null) {
			hash4 = x.hashCode();
		}
		if (y != null) {
			hash5 = y.hashCode();
		}
		return (((((((hash1 * 31) ^ hash2) * 31) ^ hash3) * 31) ^ hash4) * 31) * hash5;
	}

	@Override
	public boolean equals(Object o) {
		if (o == null) {
			return false;
		}
		if (o instanceof Tuple5<?, ?, ?, ?, ?>) {
			Tuple5<?, ?, ?, ?, ?> t = (Tuple5<?, ?, ?, ?, ?>) o;
			boolean eq1 = (u == t.u) || (u != null && u.equals(t.u)); 
			boolean eq2 = (v == t.v) || (v != null && v.equals(t.v)); 
			boolean eq3 = (w == t.w) || (w != null && w.equals(t.w)); 
			boolean eq4 = (x == t.x) || (x != null && x.equals(t.x)); 
			boolean eq5 = (y == t.y) || (y != null && y.equals(t.y)); 
			return eq1 && eq2 && eq3 && eq4 && eq5;
		}
		return false;
	}

	private U u;
	private V v;
	private W w;
	private X x;
	private Y y;

}
